import 'package:flutter_easy_protector/flutter_easy_protector.dart';

class SecurityUtils {
  SecurityUtils._();

  /// 插件是否是debug模式
  static Future<bool> get checkIsDebug async => await FlutterEasyProtector.checkIsDebug;

  /// 检查端口是否使用
  static Future<bool> checkIsPortUsing(String host, int port) async =>
      await FlutterEasyProtector.checkIsPortUsing(host, port);

  /// usb充电辅助判断
  static Future<bool> get checkIsUsbCharging async => await FlutterEasyProtector.checkIsUsbCharging;

  /// 是否root权限
  static Future<bool> get checkIsRoot async => await FlutterEasyProtector.checkIsRoot;

  /// 是否存在xp框架
  static Future<bool> get checkIsXposedExist async => await FlutterEasyProtector.checkIsXposedExist;

  /// 尝试关闭XP框架
  static Future<bool> get checkXposedExistAndDisableIt async {
    final bool isExposedFramework = await checkIsXposedExist;
    if (isExposedFramework) {
      return await FlutterEasyProtector.checkXposedExistAndDisableIt;
    }
    return false;
  }

  /// 检查是否加载某个so库
  static Future<bool> checkHasLoadSO(String soName) async {
    if (soName.trim().length > 0) {
      return await FlutterEasyProtector.checkHasLoadSO(soName);
    }
    return false;
  }

  /// java读取/proc/uid/status文件里TracerPid的方式来检测是否被调试
  static Future<bool> get checkIsBeingTracedByJava async => await FlutterEasyProtector.checkIsBeingTracedByJava;

  /// 是否模拟器运行
  static Future<bool> get checkIsRunningInEmulator async => await FlutterEasyProtector.checkIsRunningInEmulator;

  /// 是否多开
  static Future<bool> checkIsRunningInVirtualApk(String uniqueMsg) async =>
      await FlutterEasyProtector.checkIsRunningInVirtualApk(uniqueMsg);
}
